<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>XX题库 - 注册</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3B82F6',
                        secondary: '#10B981',
                        accent: '#8B5CF6',
                        dark: '#1F2937',
                        muted: '#6B7280',
                    },
                    fontFamily: {
                        inter: ['Inter', 'sans-serif'],
                    },
                    boxShadow: {
                        'card': '0 10px 30px -5px rgba(0, 0, 0, 0.1)',
                    },
                    animation: {
                        'float': 'float 6s ease-in-out infinite',
                    },
                    keyframes: {
                        float: {
                            '0%, 100%': { transform: 'translateY(0)' },
                            '50%': { transform: 'translateY(-10px)' },
                        }
                    }
                }
            }
        }
    </script>
    
    <!-- 自定义样式 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .education-bg {
                background-image: url('https://picsum.photos/id/180/1920/1080');
                background-size: cover;
                background-position: center;
                background-attachment: fixed;
            }
            .tab-active {
                @apply text-primary border-primary font-medium;
            }
            .tab-inactive {
                @apply text-muted hover:text-primary border-transparent;
            }
        }
    </style>
</head>
<body class="font-inter bg-gray-50 min-h-screen flex items-center justify-center education-bg">
    <!-- 背景装饰元素 -->
    <div class="absolute inset-0 overflow-hidden -z-10">
        <div class="absolute top-10 left-10 w-40 h-40 rounded-full bg-primary/10 animate-float">
            <div class="w-full h-full flex items-center justify-center text-primary/20 text-6xl">
                <i class="fa fa-book"></i>
            </div>
        </div>
        <div class="absolute bottom-20 right-20 w-60 h-60 rounded-full bg-secondary/10 animate-float" style="animation-delay: -2s">
            <div class="w-full h-full flex items-center justify-center text-secondary/20 text-7xl">
                <i class="fa fa-graduation-cap"></i>
            </div>
        </div>
        <div class="absolute top-1/3 right-1/4 w-32 h-32 rounded-full bg-accent/10 animate-float" style="animation-delay: -4s">
            <div class="w-full h-full flex items-center justify-center text-accent/20 text-5xl">
                <i class="fa fa-lightbulb-o"></i>
            </div>
        </div>
    </div>

    <!-- 注册卡片 -->
    <div class="w-full max-w-md px-6 py-8 bg-white rounded-2xl shadow-card relative overflow-hidden">
        <!-- 顶部装饰条 -->
        <div class="absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary to-accent"></div>
        
        <!-- 标题区域 -->
        <div class="text-center mb-6">
            <h1 class="text-[clamp(1.5rem,3vw,2rem)] font-bold text-dark">XX题库注册</h1>
            <p class="text-muted mt-2">创建账号，开启学习之旅</p>
        </div>
        
        <!-- 选项卡导航 -->
        <div class="border-b border-gray-200 mb-6">
            <div class="flex -mb-px">
                <button id="phoneTab" class="tab-active px-4 py-2 text-sm font-medium border-b-2 transition-all duration-200">
                    手机注册
                </button>
                <button id="emailTab" class="tab-inactive px-4 py-2 text-sm font-medium border-b-2 transition-all duration-200">
                    邮箱注册
                </button>
            </div>
        </div>
        
        <!-- 注册表单 -->
        <form id="registerForm" class="space-y-5">
            <!-- 手机注册表单 -->
            <div id="phoneRegister" class="space-y-5">
                <!-- 手机号 -->
                <div class="space-y-2">
                    <label for="phone" class="block text-sm font-medium text-dark">手机号</label>
                    <div class="relative">
                        <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                            <i class="fa fa-phone"></i>
                        </span>
                        <input type="tel" id="phone" name="phone" 
                               class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                               placeholder="请输入手机号">
                    </div>
                </div>
                
                <!-- 验证码 -->
                <div class="space-y-2">
                    <label for="phoneCode" class="block text-sm font-medium text-dark">验证码</label>
                    <div class="flex space-x-3">
                        <div class="relative flex-1">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="fa fa-shield"></i>
                            </span>
                            <input type="text" id="phoneCode" name="phoneCode" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入验证码">
                        </div>
                        <button type="button" id="sendPhoneCode" class="bg-primary/10 text-primary px-4 py-3 rounded-lg text-sm whitespace-nowrap hover:bg-primary/20 transition-colors">
                            获取验证码
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- 邮箱注册表单 -->
            <div id="emailRegister" class="space-y-5 hidden">
                <!-- 邮箱 -->
                <div class="space-y-2">
                    <label for="email" class="block text-sm font-medium text-dark">邮箱</label>
                    <div class="relative">
                        <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                            <i class="fa fa-envelope"></i>
                        </span>
                        <input type="email" id="email" name="email" 
                               class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                               placeholder="请输入邮箱">
                    </div>
                </div>
                
                <!-- 验证码 -->
                <div class="space-y-2">
                    <label for="emailCode" class="block text-sm font-medium text-dark">验证码</label>
                    <div class="flex space-x-3">
                        <div class="relative flex-1">
                            <span class="absolute inset-y-0 left-0 flex items-center pl-3 text-muted">
                                <i class="fa fa-shield"></i>
                            </span>
                            <input type="text" id="emailCode" name="emailCode" 
                                   class="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/30 focus:border-primary transition-all duration-200 outline-none"
                                   placeholder="请输入验证码">
                        </div>
                        <button type="button" id="sendEmailCode" class="bg-primary/10 text-primary px-4 py-3 rounded-lg text-sm whitespace-nowrap hover:bg-primary/20 transition-colors">
                            获取验证码
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- 同意条款 -->
            <div class="flex items-start">
                <div class="flex items-center h-5">
                    <input id="terms" name="terms" type="checkbox" class="w-4 h-4 border border-gray-300 rounded focus:ring-primary/30 focus:ring-offset-0 text-primary">
                </div>
                <div class="ml-3 text-sm">
                    <label for="terms" class="text-muted">我已阅读并同意 <a href="#" class="text-primary hover:underline">用户协议</a> 和 <a href="#" class="text-primary hover:underline">隐私政策</a></label>
                </div>
            </div>
            
            <!-- 注册按钮 -->
            <button type="submit" class="w-full py-3 bg-primary hover:bg-primary/90 text-white font-medium rounded-lg transition-all duration-200 transform hover:-translate-y-1 hover:shadow-lg flex items-center justify-center">
                <span>立即注册</span>
                <i class="fa fa-arrow-right ml-2"></i>
            </button>
            
            <!-- 已有账号 -->
            <div class="text-center text-sm">
                <span class="text-muted">已有账号？</span>
                <a href="#" class="text-primary hover:underline">立即登录</a>
            </div>
        </form>
    </div>

    <!-- 页脚 -->
    <div class="absolute bottom-6 text-center text-sm text-muted">
        <p>© 2023 XX题库. 保留所有权利.</p>
    </div>

    <!-- JavaScript -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            const phoneTab = document.getElementById('phoneTab');
            const emailTab = document.getElementById('emailTab');
            const phoneRegister = document.getElementById('phoneRegister');
            const emailRegister = document.getElementById('emailRegister');
            const sendPhoneCodeBtn = document.getElementById('sendPhoneCode');
            const sendEmailCodeBtn = document.getElementById('sendEmailCode');
            
            // 切换选项卡
            phoneTab.addEventListener('click', function() {
                phoneTab.classList.remove('tab-inactive');
                phoneTab.classList.add('tab-active');
                emailTab.classList.remove('tab-active');
                emailTab.classList.add('tab-inactive');
                phoneRegister.classList.remove('hidden');
                emailRegister.classList.add('hidden');
            });
            
            emailTab.addEventListener('click', function() {
                emailTab.classList.remove('tab-inactive');
                emailTab.classList.add('tab-active');
                phoneTab.classList.remove('tab-active');
                phoneTab.classList.add('tab-inactive');
                emailRegister.classList.remove('hidden');
                phoneRegister.classList.add('hidden');
            });
            
            // 发送验证码倒计时
            function startCountdown(button) {
                let countdown = 60;
                button.disabled = true;
                button.classList.remove('bg-primary/10', 'hover:bg-primary/20');
                button.classList.add('bg-gray-200', 'text-gray-500');
                button.textContent = `重新发送(${countdown}s)`;
                
                const timer = setInterval(() => {
                    countdown--;
                    button.textContent = `重新发送(${countdown}s)`;
                    
                    if (countdown <= 0) {
                        clearInterval(timer);
                        button.disabled = false;
                        button.classList.remove('bg-gray-200', 'text-gray-500');
                        button.classList.add('bg-primary/10', 'hover:bg-primary/20', 'text-primary');
                        button.textContent = '获取验证码';
                    }
                }, 1000);
            }
            
            // 发送手机验证码
            sendPhoneCodeBtn.addEventListener('click', function() {
                const phoneInput = document.getElementById('phone');
                const phoneValue = phoneInput.value.trim();
                
                // 简单验证手机号格式
                if (!phoneValue) {
                    alert('请输入手机号');
                    return;
                }
                
                // 手机号格式验证（简化版）
                if (!/^1[3-9]\d{9}$/.test(phoneValue)) {
                    alert('请输入有效的手机号');
                    return;
                }
                
                // 模拟发送验证码
                console.log('发送验证码到手机:', phoneValue);
                startCountdown(this);
            });
            
            // 发送邮箱验证码
            sendEmailCodeBtn.addEventListener('click', function() {
                const emailInput = document.getElementById('email');
                const emailValue = emailInput.value.trim();
                
                // 简单验证邮箱格式
                if (!emailValue) {
                    alert('请输入邮箱');
                    return;
                }
                
                // 邮箱格式验证（简化版）
                if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue)) {
                    alert('请输入有效的邮箱地址');
                    return;
                }
                
                // 模拟发送验证码
                console.log('发送验证码到邮箱:', emailValue);
                startCountdown(this);
            });
            
            // 表单提交
            document.getElementById('registerForm').addEventListener('submit', function(e) {
                e.preventDefault();
                
                // 检查是否同意条款
                const termsCheckbox = document.getElementById('terms');
                if (!termsCheckbox.checked) {
                    alert('请同意用户协议和隐私政策');
                    return;
                }
                
                // 根据当前激活的选项卡获取表单数据
                let formData = {};
                if (phoneTab.classList.contains('tab-active')) {
                    formData = {
                        registerType: 'phone',
                        phone: document.getElementById('phone').value,
                        code: document.getElementById('phoneCode').value
                    };
                } else {
                    formData = {
                        registerType: 'email',
                        email: document.getElementById('email').value,
                        code: document.getElementById('emailCode').value
                    };
                }
                
                // 简单验证
                if (!formData.code) {
                    alert('请输入验证码');
                    return;
                }
                
                // 模拟提交
                console.log('注册表单数据:', formData);
                alert('注册成功！系统将为您生成随机密码并发送到您的手机/邮箱');
            });
        });
    </script>
</body>
</html>
    